Skip to content

feat(#234): wire live Infracost pricing for WAFv2 web ACL metrics - #236

Merged
elecnix merged 2 commits into
mainfrom
feat/234-wafv2-live-descriptors
Jul 6, 2026
Merged

feat(#234): wire live Infracost pricing for WAFv2 web ACL metrics#236
elecnix merged 2 commits into
mainfrom
feat/234-wafv2-live-descriptors

Conversation

@elecnix

@elecnix elecnix commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Follow-up to #235 (the WAFv2 web ACL handler). Wires live Infracost pricing for
the three WAFv2 usage metrics, so the catalog is populated from a live sync
instead of relying on the seed rows. Same split as the KMS handler (handler in
#214, descriptors in #218).

Changes

  • infra_cost_model/pricing/sources/infracost.py — add _METRIC_DESCRIPTORS
    entries for WAF-WebACL-Month, WAF-Rule-Month, WAF-Request.
  • tests/test_infracost_client.py — descriptor presence, REGION_PREFIX
    resolution (us-east-1 → USE1, ca-central-1 → CAN1), and an end-to-end mocked
    sync_to_cache upsert.

Grounding

Values come from Infracost's own resource definition
(internal/resources/aws/wafv2_web_acl.go):

  • Service awswaf, product family Web Application Firewall.
  • Usagetypes <REGION>-WebACLV2, <REGION>-RuleV2, <REGION>-RequestV2-Tier1.
    Exact-match on the resolved usagetype naturally excludes the
    ShieldProtected- siblings that Infracost filters out with a
    (?!ShieldProtected-) regex.

No unit filter: each usagetype resolves to a single price row, so filtering by
unit would only risk a spurious miss on an unverified unit string. The engine
computes quantity × price directly, and Infracost returns WAF request pricing
per single request (the "1M requests" label upstream is only a display
UnitMultiplier), so it matches the handler's per-request seed row.

Tests

pytest tests/test_infracost_client.py — 45 passed. Full suite green.

The HTTP layer is mocked (as with every descriptor test), so CI validates the
request shape, not live values — the live sync is exercised by the downstream
consumer's cost-model CI, which runs a real Infracost sync and prints a per-node
breakdown.

Follow-up to the WAFv2 handler (#235), mirroring the KMS split (handler #214,
descriptors #218): add Infracost _METRIC_DESCRIPTORS for the three WAFv2
usage metrics so a live pricing sync populates the catalog.

Grounded in Infracost's own resource definition (infracost/infracost,
internal/resources/aws/wafv2_web_acl.go): service "awswaf", product family
"Web Application Firewall", usagetypes <REGION>-WebACLV2 / -RuleV2 /
-RequestV2-Tier1. The region prefix is resolved at query time; the exact-match
usagetype naturally excludes the "ShieldProtected-" siblings.

Tests mock the HTTP layer (mirroring the KMS descriptor tests): descriptor
presence, REGION_PREFIX resolution for us-east-1 (USE1) and ca-central-1
(CAN1), and an end-to-end sync_to_cache upsert.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@elecnix
elecnix marked this pull request as ready for review July 6, 2026 16:22
Infracost prices WAF under the lowercase service code "awswaf", but the handler
and seed rows use the uppercase "AWSWAF" convention (matching AWSKMS / AmazonALB
/ AWSSecretsManager). Without a remap the live-synced rows land under "awswaf"
and the case-sensitive catalog query for "AWSWAF" misses them — silently falling
back to embedded rates. `store_service: "AWSWAF"` upserts them under the queried
name, the same remap the NAT Gateway descriptor uses (AmazonEC2 → AmazonVPC).

Verified against live Infracost (us-east-1 + ca-central-1): each metric resolves
to exactly one row and an "AWSWAF" query returns $5.00 web ACL, $1.00/rule,
$0.0000006/request.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@elecnix
elecnix merged commit 8d41d0e into main Jul 6, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant